package model;

import exciptions.InvalidPasswordtException;
// this is test num2
public class User {
	private String loginName;// OOOO im late
	private String password;
	private String name;
	private String email;
	public User(String loginName) {
		
		this.loginName = loginName;
	}
	public String getLoginName() {
		return loginName;
	}
	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String pass)throws InvalidPasswordtException{
		
		boolean cap = false, num = false, smal= false;
		char c;
		for (int i =0; i<pass.length(); i++){
			c = pass.charAt(i);
			if ((c+"").matches("[A-Z]")){
				cap= true;
			}
			if ((c+"").matches("[0-9]")){
				num = true;
			}
			if ((c+"").matches("[a-z]")){
				smal = true;
			}
		}
// why im coding as comments :\
		
		if(pass.length()>7 && cap && num && smal){
				this.password = pass;
		}
		else{
			throw new InvalidPasswordtException ("Ivalid Password, must be 8 letter long, contain one capital letter and one number ");
		}
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	@Override
	public String toString() {
		return "User ["
				+ (loginName != null ? "loginName=" + loginName + ", " : "")
				+ (password != null ? "password=" + password + ", " : "")
				+ (name != null ? "name=" + name + ", " : "")
				+ (email != null ? "email=" + email : "") + "]";
	}
	
	
}
